# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : code05.py
# @Time     : 2024/4/6 18:49
# @Author   : Robot-Zsj
"""
description:

input:
4
1 1 2 2

10
1 1 1 1 1 9 8 3 7 10

output:
2

3
"""
n = int(input())
nums = list(map(int, input().split()))


def getResult():
    sumV = sum(nums)

    # 不能平分，直接返回-1
    if sumV % 2 != 0:
        return -1

    # 可能可以平分
    bag = sumV // 2
    # 初始化
    dp = [[0] * (bag + 1) for _ in range(n + 1)]

    # 设置边界
    for i in range(1, bag + 1):
        dp[0][i] = n
    """
    0 4 4 4
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    """
    for i in range(1, n + 1):
        num = nums[i - 1]
        for j in range(1, bag + 1):
            if j < num:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - num] + 1)
    # 如果装满背包的最少物品数为n，则说明没有平分方案，因为n个雨花石的重量之和为sumV，而背包的承重是bag=sumV//2
    if dp[n][bag] == n:
        return -1
    else:
        return min(n - dp[n][bag], dp[n][bag])


print(getResult())
